<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		div{
			float: left;
			margin:10px;
		}
		#face{
			width:50px;
			height:50px;
			background-color: red;
		}
		#title{
			background-color: blue;
			width: 500px;
			height: 200px;
			display: none;
		}
	</style>
	<script type="text/javascript">
		window.onload=function(){
			var face=document.getElementById('face');
			var title=document.getElementById('title');
            var closeTime=null;

            //连等写法，缩减语法
            title.onmouseover=face.onmouseover=function(){
            	clearTimeout(closeTime);
            	title.style.display='block';
            };

            title.onmouseout=face.onmouseout=function(){
                closeTime = setTimeout(function(){
                	title.style.display='none'
                },2000)
            };
            


            // title.onmouseover=function(){
            // 	clearTimeout(closeTime);
            // 	title.style.display='block';
            // };

            // title.onmouseout=function(){
            // 	closeTime = setTimeout(function(){
            //     	title.style.display='none'
            //     },2000);
            // };
            
		}
	</script>
</head>
<body>
	<div id="face"></div>
	<div id="title"></div>
</body>
</html>